package com.project.config.rabbitMQ;


import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * ClassName: PayRabbitMQ <br/>
 * Description: <br/>
 * date: 2019/1/4 9:56<br/>
 *
 * @author lenovo<br />
 * @since JDK 1.8
 */
@Configuration
public class PayRabbitMQ {

    @Resource(name = "payCallback")
    private PayCallback payCallback;

    @Bean
    public Queue newQueue(){
        return new Queue("register");
    }

    @Bean
    public TopicExchange newTopicExchange(){
        return new TopicExchange("payExchange");
    }


    @Bean
    public Binding  setBinding(){
        return  BindingBuilder.bind(newQueue()).to(newTopicExchange()).with("#.register.project");
    }

    @Resource(name = "rabbitTemplate")
    public  void setPayCallback(RabbitTemplate rabbitTemplate){
        rabbitTemplate.setConfirmCallback(payCallback);
        rabbitTemplate.setReturnCallback(payCallback);
    }

}
